import { app } from "electron";
import * as os from "os";
/**
 * 获取当前是否是自动开机
 * @returns
 */
export const getIsAutoRunning = () => {
    const { openAtLogin } = app.getLoginItemSettings({
        args: ["--openAsHidden"],
    });
    return openAtLogin;
};

export const setAutoRunningStatus = (isAutoRunning: boolean) => {
    if (!app.isPackaged) return;

    const osType = os.type();
    if (osType == "Windows_NT") {
        app.setLoginItemSettings({
            openAtLogin: isAutoRunning,
            args: ["--openAsHidden"],
        });
    } else {
        app.setLoginItemSettings({
            openAtLogin: isAutoRunning,
            openAsHidden: true,
        });
    }
};
